package user_assets_usdt

import (
	"context"
	"strconv"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUsdtWalletUpdateInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 更新
func NewUserUsdtWalletUpdateInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUsdtWalletUpdateInfoLogic {
	return &UserUsdtWalletUpdateInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserUsdtWalletUpdateInfoLogic) UserUsdtWalletUpdateInfo(req *types.UserUSDTWalletUpdateRequest) (resp *types.UserUSDTWalletUpdateResponse, err error) {
	_, err = l.svcCtx.AssetsRpc.UserChannel.UserUsdtWalletsUpdate(l.ctx, &rpc.UserUsdtWalletsUpdateRequest{
		Id:       req.ID,
		UserId:   req.UserID,
		UsdtType: strconv.FormatInt(req.UsdtType, 10),
		Address:  req.Address,
	})
	if err != nil {
		return &types.UserUSDTWalletUpdateResponse{
			IsUpdate: false,
		}, nil
	}
	return &types.UserUSDTWalletUpdateResponse{
		IsUpdate: true,
	}, nil
}
